import { http as request } from '@/http/http'

// 仓库管理--库位信息 VO
export interface RackLocationVO {
  id: number // 主键ID
  locationCode: string // 库位编码
  rackId: number // 所属货架ID
  warehouseId: number // 所属仓库ID
  rowNo: number // 所在层
  columnNo: number // 所在列
  locationType: number // 库位类型(0-常规,1-危险品,2-冷藏等)
  capacity: number // 最大容量
  usedCapacity: number // 已用容量
  volume: number // 库位容积(m³)
  maxWeight: number // 最大承重(kg)
  status: number // 状态(0-可用,1-占用,2-锁定)
  barcode: string // 库位条码
  qrCode: string // 库位二维码
  remark: string // 备注
}

// 仓库管理--库位信息 API
export const RackLocationApi = {
  // 查询仓库管理--库位信息分页
  getRackLocationPage: async (params: any) => {
    return await request.get(`/wms/rack-location/page`, params)
  },
  // 查询仓库管理--库位精简信息列表
  getRackLocationList: async (id?: any) => {
    const url = id
      ? `/wms/rack-location/simple-list?rackId=${id}`
      : `/wms/rack-location/simple-list`
    return await request.get(url)
  },
  // 查询仓库管理--库位信息详情
  getRackLocation: async (id: number) => {
    return await request.get(`/wms/rack-location/get?id=${id}`)
  },

  // 新增仓库管理--库位信息
  createRackLocation: async (data: RackLocationVO) => {
    return await request.post(`/wms/rack-location/create`, data)
  },

  // 修改仓库管理--库位信息
  updateRackLocation: async (data: RackLocationVO) => {
    return await request.put(`/wms/rack-location/update`, data)
  },

  // 删除仓库管理--库位信息
  deleteRackLocation: async (id: number) => {
    return await request.delete(`/wms/rack-location/delete?id=${id}`)
  },

  // 导出仓库管理--库位信息 Excel
  // exportRackLocation: async (params) => {
  //   return await request.download(  `/wms/rack-location/export-excel`, params )
  // },

  // 货架信息精简列表
  getWarehouseRackList: async (id?: number) => {
    const url = id
      ? `/wms/warehouse-rack/simple-list?warehouseId=${id}`
      : `/wms/warehouse-rack/simple-list`
    return await request.get(url)
  },
}
